#include <libpaysql.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>



int main(int argc,char** argv)
{
    if(argc<3)
    {
	printf("USAGE: makebatch [USER]:[PASS]@[HOST]/DBASE COUNT\n");
	return 0;
    }

    srand(time(0));

    char phone[255]="8888888888";
    double amount=0.;
	
    CMySQLConnection sql;
    if(!sql.Connect(argv[1]))
	printf("%s\n",sql.GetLastError());
    else
    {
	for (int i=0;i<atoi(argv[2]);i++)
	{
//	    sprintf(phone,"916%.7i",(int)(1+(int)(9999999.0*rand()/(RAND_MAX+1.0))));
	    amount = (double) (1 + (6.0*rand() / (RAND_MAX+1.0)));
	    CPayRequest req(sql);
	    int n = req.SendRequest(REQ_PHONECHECK,0,phone,amount);
	    if (n < 0)
	    {
	        printf("%s\n",sql.GetLastError());
		break;
	    }
	    else printf("%i- SUCCESS. REQID=%i\n",i+1,n);
	}
    }
    return 0;
}
